package itheima.moc.TestServerSocketDemo8;

import java.io.*;
import java.net.Socket;

public class SocketDemo {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 5555);
        // 将本地文件读取
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Day15\\Client\\1.jpg"));
        //创建网络中的流
        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());

        int a;
        while ((a = bis.read()) != -1) {
            bos.write((char) a);
        }

        socket.shutdownOutput();

        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }

        bis.close();
        br.close();
        socket.close();

    }
}
